import { Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn } from 'typeorm';
import { Gateway } from './gateway.entity';
import { Wristband } from './wristband.entity';
// import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
// import { Gateway } from './gateway.entity';
// import { Wristband } from './wristband.entity';

@Entity('gateway_wristband')
export class GatewayWristband {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column('char', { length: 17, name: 'gw_mac' })
  gw_mac: string;  // 网关MAC地址

  @Column({ type: 'text', nullable: true })
  wb_mac: string; // 手环MAC地址

  @Column('tinyint', { nullable: false, default: 0 })  // 添加默认值
  deleted: number;


  // 一对一关系：一个关联记录对应一个网关
  @OneToOne(() => Gateway)
  @JoinColumn({ name: 'gw_mac', referencedColumnName: 'mac' })
  student: Gateway;

  // 一对一关系：一个关联记录对应一个手环
  @OneToOne(() => Wristband)
  @JoinColumn({ name: 'wb_mac', referencedColumnName: 'mac' })
  wristband: Wristband;
  
}
